package JDBC;

import java.util.Objects;

/**
 * 预设的User类,对接后删除
 * @Author Alex
 */
public class User {

    private Integer id;
    private String name;
    private String psw;

    public User() {
    }

    public User(String name, String psw) {
        this.name = name;
        this.psw = psw;
    }

    public User(Integer id, String name, String psw) {
        this.id = id;
        this.name = name;
        this.psw = psw;
    }

    public int getId() {
        return id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getPsw() {
        return psw;
    }

    public void setPsw(String psw) {
        this.psw = psw;
    }

    @Override
    public String toString() {
        return "User{" +
                "id=" + id +
                ", name='" + name + '\'' +
                ", psw='" + psw + '\'' +
                '}';
    }

    //此处重写的方法忽略了id的比较,只比较name和psw
    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }
        User user = (User) o;
        return Objects.equals(name, user.name) && Objects.equals(psw, user.psw);
    }

    @Override
    public int hashCode() {
        return Objects.hash(name, psw);
    }
}
